import { constantRoutes, asyncRoutes } from '@/router'

const state = {
  routers: constantRoutes
}

const mutations = {
  setRouter(state, otherRouter) {
    state.routers = [...constantRoutes, ...otherRouter]
  }
}

const actions = {
  filterRoutes(context, menus) {
    const otherRouter = asyncRoutes.filter(item => menus.includes(item.children[0].name))
    // console.log(asyncRoutes, 455)
    context.commit('setRouter', otherRouter)
    return otherRouter
  }
}

const getters = {

}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}
